#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：turbo 
@File    ：serializers.py
@Author  ：赵加响
@Date    ：2023/4/6 10:17 
@Desc    ：
"""
from rest_framework import serializers

from apps.rbac.models import Role
from bases.serializers import APIModelSerializer


class RoleSerializer(APIModelSerializer):
    require_fields = ('code', 'name_zh', 'name_en')
    unique_fields = ('code', 'name_zh', 'name_en')

    code = serializers.CharField(label='角色代码', max_length=32, required=False, allow_null=True, allow_blank=True)
    name_zh = serializers.CharField(label='中文名称', max_length=128, required=False, allow_null=True, allow_blank=True)
    name_en = serializers.CharField(label='英文名称', max_length=128, required=False, allow_null=True, allow_blank=True)

    class Meta:
        model = Role
        fields = ('id', 'code', 'name_zh', 'name_en', 'content', 'is_admin')
        read_only_fields = ('id', 'menu_operate')
